package org.example.newcoder_summer.Mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.newcoder_summer.pojo.Todo;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface TodoMapper {
    @Insert("insert into todo(id, head_id, user_id, task, create_time) values (#{id}, #{headId}, #{userId}, {task}, {createTime})")
    void setTodo(Todo todo);

    @Select("select * from todo where user_id = #{userId} and create_time >= DATE(#{createTime}) and create_Time <= Date_ADD(DATE(#{create_Time}), INTERVAL 1 DAY)")
    List<Todo> getTodoByUserId(int userId, LocalDateTime createTime);

    void deleteByIds(List<Integer> ids);

    @Update("update todo set task = #{task}, finish_status = #{finishStatus}, create_time = #{createTime}")
    void updateTodo(Todo todo);
}
